#ifndef GRUB_EFI_TPCM_HEADER
#define GRUB_EFI_TPCM_HEADER 1

#include <grub/file.h>
#include <grub/efi/api.h>
#include <grub/efi/efi.h>

#define C2PGUID         {0xf89ab5cd, 0x2829, 0x422f, {0xa5, 0xf3, 0x03, 0x28, 0xe0, 0x6c, 0xfc, 0xbb}}
#define MEASURE_RESULT_MASK          (0xff00)
#define MEASURE_RESULT_SHIFT         (16)
#define MEASURE_ACTION_MASK          (0x1)
#define TPCM_MAX_BUF_SIZE            128

/*
   stage layout:
     2000~2999: +1 every time
*/

#define STAGE_START      2000
#define STAGE_END        2999
#define STAGE_INVALID    3000

struct addr_range {
    grub_uint64_t start;
    grub_uint64_t length;
};
struct c2p_protocol {
    grub_efi_status_t (__grub_efi_api *verify_raw) (struct c2p_protocol *this,
                                    grub_uint32_t measure_stage,
                                    grub_uint64_t image_info,
                                    grub_uint32_t image_info_size,
                                    grub_uint32_t num_addr_range,
                                    struct addr_range ranges[],
                                    grub_uint32_t *measure_result,
                                    grub_uint32_t *control_result);
    grub_efi_boolean_t (__grub_efi_api *verify_is_enabled)(struct c2p_protocol *this);
};
typedef struct c2p_protocol c2p_protocol_t;

grub_err_t grub_tpcm_measure_memory(void *context, grub_addr_t buf, grub_size_t size);

#endif
